package datamining.code.insert;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.SQLException;

import datamining.code.dao.TransactionDAO;

public class InsertTransaction {
	
	private static File input;
	private static FileReader fileReader;
	private static BufferedReader bufferedReader;
	private static String line;
	
	public static void main(String[] args) {
		TransactionDAO dao = new TransactionDAO();
		try {
			
			input = new File("csvtables/databaseready/emprestimo.csv");
			fileReader = new FileReader(input);
			bufferedReader = new BufferedReader(fileReader);
			
			while((line = bufferedReader.readLine()) !=null){
				String[] transaction = line.split(";");
				dao.create(transaction);
			}
			System.out.println("Done.");

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			System.out.println(e.getMessage());
			e.printStackTrace();
		}		
	}

}
